#include "LimTorqueCheck.h"

#include "Parameters.h"
#include "TotalTorque.h"

#include <cmath>
#include <iostream>

LimTorqueCheck::LimTorqueCheck(Clock clock,Pulse *field,Pulse *current,MultiLayer multiLayer,NewParameters params)
{
  double norm=0;
  Vector3 torque;
  int layerNumber=multiLayer.getSolveLayer(); 

  if(multiLayer[layerNumber].getFrozen()==false)
    {
      torque=TotalTorque(clock,field,current,multiLayer,layerNumber,params);
      norm=sqrt(torque.dotProduct(torque));
      //std::cout<<"torque"<<norm<<std::endl;
      if(norm>params.getTorque()["limit"])
	check=false;
      else check=true;
    }
}

LimTorqueCheck::~LimTorqueCheck()
{

}
